<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript" src="__PUBLIC__/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/easyui/locale/easyui-lang-zh_CN.js"></script>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/gray/easyui.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/icon.css">
    <script type="text/javascript" src="__PUBLIC__/js/add-tab.js"></script>

    <style type="text/css">
        .perPanel {
            position: absolute;
            top:10px;
            left: 10px;
            width:400px;
            height:auto; 
        }

        .phoneNumPanel{
            position: absolute;
            top:10px;
            left: 420px;
            width: 510px;
            height: auto;
        }
    
        .contentPanel{
            position: absolute;
            top:200px;
            left: 420px;
            width: 510px;
            height: auto;
        }

        .fasong{
            float: right;
        }
    </style>

    <script type="text/javascript">
        $(function(){
            $('#permisson').tree({
                url:'__APP__/Tool/dptData',
                animate:true,
                lines:true,
                checkbox:true,
                onLoadSuccess: function (row, data) {
                    $('#permisson').tree("collapseAll");
                },
                onCheck:function(node){
                    var nodes = $('#permisson').tree('getChecked');
                    var s = [];
                    for(var i=0; i<nodes.length; i++){
                        s.push(nodes[i].text);
                    }
                    var s=s.toString();
                    var temp='';
                    var num='';
                    var a = s.split(":") ;
                    for(i=0;i<a.length;i++){
                        num = a[i].substr(0,11);
                        if(isphone(num)){
                            temp +=num+',';
                        }
                    }
                    temp=temp.substr(0,temp.length-1); 
                    $('#phone_num').val(temp);
                    
                }
            });

            $(".fasong").click(function(){
                var phone=phone_num=$("#phone_num").val();
                var content=$("#content").val();
                if(phone_num){
                    var sign=1;
                    var phone_num=phone_num.toString();
                    var num='';
                    var a = phone_num.split(",") ;
                    for(i=0;i<a.length;i++){
                        num = a[i].substr(0,11);
                        if(!isphone(num)){
                            sign=0;
                        }
                    }
                    if(sign){
                        if(content){
                            $.ajax({
                                url:'__APP__/Tool/fasong',
                                type:'post',
                                data:{phone_num:phone,content:content},
                                success:function(data){
                                    $.messager.alert('提示',data,'info');
                                }
                            })
                        }
                        else{
                            $.messager.alert('提示','请填写发送内容','error');
                        }    
                    }
                    else{
                        $.messager.alert('提示','接受人手机号码错误，或英文的逗号隔开每个手机号码','error');
                    }
                    
                }
                else{
                    $.messager.alert('提示','请选择或填写接受人手机号码','error');
                }
            })
        })

        function isphone(inputString){
            var partten = /^1[3,5,8]\d{9}$/;
            var fl=false;
            if(partten.test(inputString)){
              return true;
            }
            else{
              return false;
            }
        }

    </script>
 
</head>
<body>
<div class="perPanel">
    <div class="easyui-panel" title="选择员工">
        <ul id="permisson" style="min-height:200px;">

        </ul>
    </div>
</div>


<div class="phoneNumPanel">
    <div class="easyui-panel" title="接受人号码：">
        <textarea id="phone_num" style="min-height: 100px; width: 500px"></textarea>
    </div>
</div>

<div class="contentPanel">
    <div class="easyui-panel" title="内容：">
        <textarea id="content" style="min-height: 100px; width: 500px"></textarea>
        <a href="javascript:void(0);" class="easyui-linkbutton fasong" iconCls="icon-contacts">发送</a>
    </div>
</div>
</body>
</html>